package com.ruoyi.web.controller.operation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GwPlatformRights;
import com.ruoyi.system.service.IGwPlatformRightsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台权益Controller
 * 
 * @author ruoyi
 * @date 2025-05-08
 */
@Api(description = "平台运营管理-平台权益发布")
@RestController
@RequestMapping("/system/platformRights")
public class GwPlatformRightsController extends BaseController
{
    @Autowired
    private IGwPlatformRightsService gwPlatformRightsService;

    /**
     * 查询平台权益列表
     */
    @ApiOperation("查询平台权益列表-分页")
    @GetMapping("/list")
    public TableDataInfo list(GwPlatformRights gwPlatformRights)
    {
        startPage();
        List<GwPlatformRights> list = gwPlatformRightsService.selectGwPlatformRightsList(gwPlatformRights);
        return getDataTable(list);
    }

    /**
     * 查询平台权益列表
     */
    @ApiOperation("查询平台权益列表--(企业开户管理可用)")
//    @PreAuthorize("@ss.hasPermi('system:platformRights:list')")
    @GetMapping("/platformRightsList")
    public AjaxResult platformRightsList(GwPlatformRights gwPlatformRights)
    {
        List<GwPlatformRights> list = gwPlatformRightsService.selectGwPlatformRightsList(gwPlatformRights);
        return AjaxResult.success(list);
    }

    /**
     * 导出平台权益列表
     */
//    @PreAuthorize("@ss.hasPermi('system:platformRights:export')")
    @Log(title = "平台权益", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwPlatformRights gwPlatformRights)
    {
        List<GwPlatformRights> list = gwPlatformRightsService.selectGwPlatformRightsList(gwPlatformRights);
        ExcelUtil<GwPlatformRights> util = new ExcelUtil<GwPlatformRights>(GwPlatformRights.class);
        util.exportExcel(response, list, "平台权益数据");
    }

    /**
     * 获取平台权益详细信息
     */
    @ApiOperation("获取平台权益详情")
//    @PreAuthorize("@ss.hasPermi('system:platformRights:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gwPlatformRightsService.selectGwPlatformRightsById(id));
    }

    /**
     * 新增平台权益
     */
    @ApiOperation("新增平台权益")
//    @PreAuthorize("@ss.hasPermi('system:platformRights:add')")
    @Log(title = "平台权益", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GwPlatformRights gwPlatformRights)
    {
        return toAjax(gwPlatformRightsService.insertGwPlatformRights(gwPlatformRights));
    }

    /**
     * 修改平台权益
     */
    @ApiOperation("修改平台权益")
//    @PreAuthorize("@ss.hasPermi('system:platformRights:edit')")
    @Log(title = "平台权益", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GwPlatformRights gwPlatformRights)
    {
        return toAjax(gwPlatformRightsService.updateGwPlatformRights(gwPlatformRights));
    }

    /**
     * 删除平台权益
     */
    @ApiOperation("删除平台权益")
//    @PreAuthorize("@ss.hasPermi('system:platformRights:remove')")
    @Log(title = "平台权益", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gwPlatformRightsService.deleteGwPlatformRightsByIds(ids));
    }
}
